#include <iostream>
#include <fstream>
#include "point.h"
#include "face.h"
#include "sommet.h"
#include "fenetreopengl.h"
#include "htexture.h"
#include "materiaux.h"
#include "transformation.h"
#include "rotation.h"


#include <QList>
#include <QApplication>
#include <QVBoxLayout>
#include <QLCDNumber>
#include <QSlider>



//On utilise l'espace de nom std::ostream
using std::ostream;


Scene* scene;


/*
 * Classse permettant de tester une fenetre opengl
 *
 */
class MyWidget : public QWidget
{
public:
    MyWidget(QWidget *parent = 0);
};
MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    FenetreOpengl *window = new FenetreOpengl(60, this, "Fenetre opengl");

    window->setScene(*scene);


    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(window, 1);

    setLayout(layout);
    window->setFocus();
}


//Fonction principale
int main(int argc, char *argv[])
{
    /*Materiaux* mat1 = new Materiaux();
    Materiaux* mat2;

    Lumiere* lum1 = new Lumiere(0);
    Lumiere* lum2;
    //Habillage* tex1 = new HTexture("woodBox.bmp");
    //Habillage* tex2;

    Habillage* h1 = new HCouleur(1.0, 0.0, 1.0);
    Habillage* h2;
    Transformation* t1 = new Translation(1.0, 0.0, 0.0);
    Transformation* t2;

    Point* p1 = new Point(-1.0, -1.0, -1.0);
    Point* p2 = new Point(1.0, -1.0, -1.0);
    Point* p3 = new Point(1.0, 1.0, -1.0);
    Point* p4 = new Point(-1.0, 1.0, -1.0);
    Face* face1 = new Face();
    Sommet* s1 = new Sommet(*p1, 0.0, 0.0);
    Sommet* s2 = new Sommet(*p2, 1.0, 0.0);
    Sommet* s3 = new Sommet(*p3, 1.0, 1.0);
    Sommet* s4 = new Sommet(*p4, 0.0, 1.0);
    face1->ajouterSommet(*s1);
    face1->ajouterSommet(*s2);
    face1->ajouterSommet(*s3);
    face1->ajouterSommet(*s4);

    Face* face2;

    {
    std::ofstream ofs("fichierDeSerialisation");
    boost::archive::text_oarchive oa(ofs);
    oa << mat1;
    }

    {
    std::ifstream ifs("fichierDeSerialisation");
    boost::archive::text_iarchive ia(ifs);


    ia >> mat2;
    }

    */


    QApplication app(argc, argv);
    //initialiserScene();

    MyWidget widget;

    widget.show();

    
    return app.exec();
}










